﻿using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using MvcLearning.Models;

namespace MvcLearning
{
    public class BindableViewPage<TModel, TBinderGroup> : ViewPage<TModel>, IBindableViewPage<TModel, TBinderGroup>
    {
        public TBinderGroup BinderGroup
        {
            get { throw new NotImplementedException(); }
        }
    }

    public interface IBindableViewPage<TModel, out TBinderGroup>
    {
        HtmlHelper<TModel> Html { get; }

        TBinderGroup BinderGroup { get; }
    }

    public static class BindableViewPageExtensions
    {
        public static IViewBinder<TModel> GetBinder<TModel, TBinderGroup>(
            this IBindableViewPage<TModel, TBinderGroup> it,
            Expression<Func<TBinderGroup, Func<TModel>>> propertyExpression, 
            TModel model)
        {
            throw new NotImplementedException();
        }
    }

    public interface IViewBinder<out TModel>
    {
    }

    public static class ViewBinderExtensions
    {
        public static MvcHtmlString TextBox<TModel, TProperty>(
            this IViewBinder<TModel> viewBinder,
            Expression<Func<TModel, TProperty>> expression)
        {
            throw new NotImplementedException();
        }
    }

    public interface IRootBinderGroup<out TBinder>
    {
        TBinder RootBinder { get; }
    }

    public static class BaseBinderGroupExtensions
    {
        public static IViewBinder<TModel> RootBinder<TModel, TBinderGroup>(
            this BindableViewPage<TModel, TBinderGroup> it)
            where TBinderGroup: IRootBinderGroup<Func<TModel>>
        {
            return it.GetBinder(_ => _.RootBinder, it.Model);
        }
    }
}